﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>在数组的第2位置添加一个元素 </title>
	</head>
	<body>
		<p id="demo">点击按钮向数组添加元素。</p>
		<button onclick="a()">点一下我</button>
		<script>
			function a(){
				var f=["a","b","c","d"];
				f[4]=f[3];
				f[3]=f[2];
				f[2]=f[1];
				var s=prompt("请输入：");
				f[1]=s;
				for(var i=0;i<f.length;i++){
					document.write(f[i]);
					document.write("<br />");
				}
			}
		</script>
	</body>
</html>
